﻿/// <reference path="../../../utilities/FXDom.js" />
/// <reference path="../../../utilities/Post.js" />
/// <reference path="../../../utilities/Thread.js" />
/// <reference path="MarkupElementSelector.js" />
///--------------------------------------------------------------------
/// <file name="ViewThreadMarkupElementSelector.js">
///   A markup element selector for use during a thread view.
/// </file>
///--------------------------------------------------------------------

NAMFox.ns(function() { with (NAMFox) {

this.ViewThreadMarkupElementSelector = function(thread) {
    /// <summary>
    /// Initializes a new instance of the ViewThreadMarkupElementSelector class.
    /// </summary>
    /// <param name="thread" type="Thread">
    /// Contains data about the thread being viewed.
    /// </param>
    
    this._thread = thread;
};

ViewThreadMarkupElementSelector.prototype = new MarkupElementSelector();

ViewThreadMarkupElementSelector.prototype = {
    getElements: function() {
        /// <summary>
        /// Retrieves all of the HTML elements that contain markup to strip.
        /// </summary>
        /// <returns type="Array" />

        var posts = this._thread.getPosts();
        
        var user = $.getCurrentUser().userName;
        var elements = [];
        $FX.each(
            posts,
            function(i, post) {
                if (post.getAuthor() !== user) {
                    var postContainer = $FX(post.contentRow).find("div[id^=em]");
                    
                    elements.push(postContainer.get(0));
                }
                else {
                    $.verbose("MARKUP STRIP | A forum post was filtered from consideration because it was the user's post.");
                }
            }
        );
        
        return elements;
    }
};

}});